<!--添加栏目-->
<div class="dialog_content">
	<form id="info_form" action="{:U('Cooperation/add')}" method="post">
		<table width="100%" class="table_form">
			<tr>
				<th>推广工具 :</th>
				<td><input type="text" name="name" id="add_name" class="input-text" size="30" value="{$info.name}"></td>
			</tr>
			<tr>
				<th>对接密匙 :</th>
				<td>
					<input type="text" name="key" id="add_key" class="input-text" size="30" value="{$info.key}">
					<span id="make_key" style="line-height: 30px; border: 1px solid #0f9ae0;padding: 5px 10px; cursor: pointer">随机</span>
				</td>
			</tr>
		</table>
		<input type="hidden" name="id" value="{$info.id}">
	</form>
</div>
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	$("#add_name").formValidator({onshow:lang.please_input+'推广工具',onfocus:lang.please_input+'推广工具'}).inputValidator({min:1,onerror:lang.please_input+'推广工具'});
	$("#add_key").formValidator({onshow:lang.please_input+'密匙',onfocus:lang.please_input+'密匙'}).inputValidator({min:1,onerror:lang.please_input+'密匙'});
	$('#info_form').ajaxForm({success:complate,dataType:'json'});
	function complate(result){
		if(result.errNum === 0){
			$.dialog.get('add').close();
			$.yhxia.tip({content:result.retData});
			window.location.reload();
		} else {
			$.yhxia.tip({content:result.errMsg, icon:'alert'});
		}
	}

	$('#make_key').click(function(){
		$.post("{:U('Cooperation/make_key')}", {}, function(str){
			$('#add_key').val(str.retData);
		});
	})
});
</script>